package com.mux.springboot;

import org.apache.catalina.Context;
import org.apache.catalina.connector.Connector;
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;


@SpringBootApplication
public class Application {
	
	public static void main(String[] args) {
		//SpringApplication.run(SampleController.class, args);  ;
		SpringApplication.run(Application.class, args) ;
		System.out.println("success");
	}
	
/*	*//**
	 * 当输入http 时，自动转向到https
	 * @return
	 * 
	 * 1.
	 *//*
	@Bean
	public EmbeddedServletContainerFactory servletContainer(){
		TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory(){
			@Override
			protected void postProcessContext(Context context){
				SecurityConstraint securityConstraint = new SecurityConstraint();
				securityConstraint.setUserConstraint("CONFIDENTIAL");
			
				SecurityCollection securityCollection = new SecurityCollection();
				securityCollection.addPattern("/*");
				
				securityConstraint.addCollection(securityCollection);
				context.addConstraint(securityConstraint);
				
			}
		};

		tomcat.addAdditionalTomcatConnectors(httpConnector());
		return tomcat;
	}
	
	*//**
	 * 2.
	 *//*
	
	@Bean
	public Connector httpConnector(){
		
		
		Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
		
		connector.setScheme("http");
		connector.setPort(8080);
		connector.setSecure(false);
		connector.setRedirectPort(8443);
		return connector;
		
		
	}*/
}